package net.lainiao.morethread.Chapter5.demo3;

import java.util.List;
import java.util.concurrent.ForkJoinPool;

/**
 * Created by Administrator on 2017/3/6.
 */
public class Main {
    public static void main(String[] args) {
        ForkJoinPool pool=new ForkJoinPool();
        FolderProcessor system=new FolderProcessor("C:\\Windows","log");
        FolderProcessor apps=new  FolderProcessor("C:\\Program Files","log");
        FolderProcessor documents=new FolderProcessor("C:\\Documents And Settings","log");
        pool.execute(system);
        pool.execute(apps);
        pool.execute(documents);
        boolean isOver=false;
        do{
            System.out.println("========================================");
            System.out.println("Main: Parallelism : "+pool.getParallelism());
            System.out.println("Main: Active Threads : "+pool.getActiveThreadCount());
            System.out.println("Main: Task Count : "+pool.getQueuedTaskCount());
            System.out.println("Main: Steal Count : "+pool.getStealCount());
            System.out.println("========================================");
        isOver=system.isDone()&&apps.isDone()&&documents.isDone();
        }while (!isOver);
        pool.shutdown();
        List<String> results;
        results=system.join();
        System.out.println("System Found file  Size:"+ results.size());
        results=apps.join();
        System.out.println("Apps Found file  Size:"+ results.size());
        results=documents.join();
        System.out.println("Documents Found file  Size:"+ results.size());
    }
}
